Ext.onReady(function(){
	Ext.QuickTips.init();
	var loginPanel=new Ext.FormPanel({
		id:'login-panel',
		region:'center',
		border:false,
		baseCls:'login-login-panel',
		autoHeight:true,
		width:300,
		labelAlign:'right',
		labelPad:10,
		labelWidth:150,
		split:true,
		
		defaultType:'textfield',
		defaults:{
			allowBlank:false,
			validationEvent:false
		},
		items:[{
				name:'jobNumber',
				fieldLabel:'用户名',
				width:130
				
			},{
				name:'password',
				fieldLabel:'密&#12288;码',
				inputType:'password',
				width:130
		}],
		buttons:[{
			text:'登&#12288;陆',
			handler:function(){
				if (!loginPanel.form.isValid())
					return;
				submitFn();
			}
		}]
	});
	var logoPanel=new Ext.Panel({
		region:'north',
		border:false,
		html:'<img src="images/vista.jpg"></img>',
		height:140
	});
	var mainPanel=new Ext.Panel({
		layout:'border',
		renderTo:document.body,
		width:400,
		height:300,
		items:[logoPanel,loginPanel,{
			region:'south',
            html:'<center>&copy;&nbsp;&nbsp;河北农大信息学院 2009</center>',
            baseCls:'footer-panel'
        }]
	});
	mainPanel.el.center();		//将面板居中
	
	//布局完毕，下面是功能性函数和设置
	//提交登陆表单函数
	var submitFn=function(){
		loginPanel.form.submit({
					url : "loginAction.action",
					success : function(){
						window.location.href='keyan_test.html';
					},
					failure : function(form,action) {
						if(action.failureType===Ext.form.Action.CONNECT_FAILURE)
							Ext.Msg.alert('错误', 'Status:'+action.response.status+':'+action.response.statusText,function(){this.findField('jobNumber').focus();},form);
						else
							Ext.Msg.alert('错误',action.result.msg,function(){this.findField('jobNumber').focus();},form);
						form.reset();
						
					}
				});
			};
	loginPanel.form.findField('jobNumber').focus();
	//添加在密码field回车提交表单功能
	loginPanel.form.findField('password').on('specialkey',function(f,e){
		if(e.getKey() == e.ENTER){
				submitFn();
		}
	});
});